package com.bum.api.bo.om;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.bum.rss.exp.om.RssEntry;

public class RssEntryExt {
	RssEntry	rssEntry;

	public RssEntryExt(RssEntry rssEntry) {
		this.rssEntry = rssEntry;
	}

	public String getTitle() {
		return rssEntry.getTitle();
	}

	public String getCode() {
		return rssEntry.getUrl();
	}

	public int getType() {
		if ("hot/1".equals(rssEntry.getUrl())) {
			return 4;
		}

		String[] parts = rssEntry.getUrl().split("/");
		int type = parts.length;
		if (type > 3) {
			return 3;
		}
		return type;
	}

	public String getIntro() {
		String intro = rssEntry.getIntro();
		if (StringUtils.isBlank(intro)) {
			return null;
		}

//		if (intro.length() > 300) {
//			intro = intro.substring(0, 300);
//			intro = intro.substring(0, intro.lastIndexOf(" "));
//		}

		return intro;
	}

	public String getMedia() {
		return rssEntry.getThumb();
	}

	public boolean isMeta() {
		return StringUtils.isNotBlank(rssEntry.getThumb()) || StringUtils.isNotBlank(rssEntry.getIntro());
	}

	// nav
	static Map<String, String>	nav	= new HashMap<String, String>();
	static {
		nav.put("<Xem thêm...>", "");
		nav.put("<...Trang trước>", "");
		nav.put("<...Trước>", "");
		nav.put("<Các chuyên mục>", "");
	}

	public boolean isPaging() {
		return nav.containsKey(rssEntry.getTitle());
	}
}
